#ifndef _WORK_THREAD_21589934_D19B_4422_8F17_F1ED513D57B2_
#define _WORK_THREAD_21589934_D19B_4422_8F17_F1ED513D57B2_
#pragma once
#include "base/threading/thread.h"

/**
 * 派生线程结果,挂接线程的初始化和结束处理过程
 */
class WorkThread :	public base::Thread {
	typedef base::Thread BASECLASS;
public:
  /**
   * 线程的执行时机回调接口
   */
	struct Delegate {
    /**
     * 线程初始化完毕回调接口
     */
		virtual void OnInit(WorkThread* thr) = 0;
    /**
     * 线程结束前回调接口
     */
		virtual void OnCleanup(WorkThread* thr) = 0;
	};

public:
  /**
   * 构造函数
   * @param name指示待创建的线程名
   * @param delegate指示回调接口
   */
	explicit WorkThread(const char *name, Delegate* delegate);

  // 往线程投递处理任务
  void PostTask(const tracked_objects::Location& from_here,
                const base::Closure& task);

protected:
	// base::Thread
	virtual void Init();
	virtual void CleanUp();

protected:
	Delegate* delegate_;
};

#endif //_WORK_THREAD_21589934_D19B_4422_8F17_F1ED513D57B2_